<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
     <link rel="icon" href="<%=request.getContextPath()%>/images/favicon.ico" type="image/x-icon" />
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/images/favicon.ico" type="image/x-icon" />
    
<script type="text/javascript">
	var rootpath = "${pageContext.request.contextPath}";
</script>
	
    <link href="<%=request.getContextPath()%>/css/themes/icon.css" rel="stylesheet" />
    <link href="<%=request.getContextPath()%>/css/themes/default/easyui.css" rel="stylesheet" />


<link href="<%=request.getContextPath()%>/css/common.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/div.css" rel="stylesheet"  type="text/css" />

    <script src="<%=request.getContextPath()%>/js/jquery.min3.3.js"></script>
    <script src="<%=request.getContextPath()%>/js/jquery.easyui.min1.9.15.js"></script>
    <script src="<%=request.getContextPath()%>/js/locale/easyui-lang-zh_CN.js"></script>
    <script src="<%=request.getContextPath()%>/js/automvc.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/js/now.js" type="text/javascript"></script>
    <script src="<%=request.getContextPath()%>/js/insertDiv.js" type="text/javascript"></script>

<style type="text/css">
#lefttop {
	float: right;
}

.date, .time, .lang, .reg {
	float: left;
}

.user-hide {
	display: none;
}
</style>


<script type="text/javascript">

 function loadMenu(){
	
	  $.ajax({ 
		    type:'post',  
		    url:rootpath+'/resource/list', 
//		    data:data,  
		    dataType:'json', 
		    
		    error:function(e){  
             $.messager.show({
					title: 'Error',
					msg: e.status+"  :  "+e.statusText
				});
         }, 
		    success: function(result){
			if (result.errorMsg){
				$.messager.show({
					title: 'Error',
					msg: result.errorMsg
				});
			} else {
// 				$.messager.show({
// 					title: 'Successfully',
// 					msg: 'Successfully!'
// 				});
				 $('#leftMenu').sidemenu({
			            data:result.rows
			            	,
			                onSelect: onSideMenuSelect,
			                border: false
			            });
			}
		}
	});
} 
 
$(function () {
	
$(".date").html(date()+"&nbsp;");
$(".time").html(time());


$("#logout").click(function(){
	   var t=location.href;
		$.post(rootpath+'/user/logout',
			     function(result){
			  	    if (result.errorMsg){
                        alert(result.errorMsg);
				    }else{
				    	//成功
// 				    	location.href=rootpath;
				    	localStorage.removeItem('loginUser');
				    	location.href="easyframe.jsp";


//                        $("#logindiv").show();
//                        $("#logoutdiv").hide();
//                        $("#loguser").hide();
//                        $("#regdiv").show();
                       
//       				   $('#leftMenu').sidemenu({
//  			                data:""
//  			            	,
//  			                onSelect: onSideMenuSelect,
//  			                border: false
//  			           });
      				 
				    }
			},'json'); 
}); 


});

function onPanelOpen() {
        var panel = $(this);
        var he = panel.panel("header").children("div.panel-tool");
        he.children("a.panel-tool-collapse").hide();

        var le = "menu-bt-left";
        var t = he.children("a." + le);
        if (!t.length) {
            t = $("<a href=\"javascript:;\"></a>").addClass(le).appendTo(he);
            t.bind("click", { dir: "left" }, function (e) {
                if (e.target.className == "menu-bt-right") {
                    e.target.className = "menu-bt-left"
                    onWestExpand();
                    panel.panel("setTitle", panel.titleTemp);
                    panel.panel('resize', {
                        width: 202
                    });

                    var leftMenuDiv = $('#leftMenuDiv');
                    leftMenuDiv.each(function () {
                        this.style.width = '202px';
                    });
                }
                else {
                    e.target.className = "menu-bt-right"
                    onWestCollapse();
                    var opt = panel.panel('options');
                    panel.titleTemp = opt.title;
                    panel.panel("setTitle", "");
                    panel.panel('resize', {
                        width: 42
                    });

                    var leftMenuDiv = $('#leftMenuDiv');
                    leftMenuDiv.each(function () {
                        this.style.width = '42px';
                    });
                }

                return false;
            });
        }
    }

    function onTabSelect(title, index) {
        var tabs = $('#mainTab');
        var tab = tabs.tabs('getTab', index);
        var menus = $('#leftMenu');
        if (menus.hasClass('sidemenu')) {
            var opts = menus.sidemenu("options");
            changeMenuSelect(menus, opts, tab[0].id);
        }
    }

    function onWestCollapse() {
        var opts = $('#leftMenu').sidemenu('options');
        if (opts.collapsed != 'collapse') {
            $('#leftMenu').sidemenu('collapse');
            $('#leftMenu').sidemenu('resize', {
                width: 40
            });
        }
    }

    function onWestExpand() {
        var opts = $('#leftMenu').sidemenu('options');
        if (opts.collapsed != 'expand') {
            $('#leftMenu').sidemenu('expand');
            $('#leftMenu').sidemenu('resize', {
                width: 200
            });
        }
    }

    function onSideMenuSelect(item) {
        if (!$('#mainTab').tabs('exists', item.text)) {
		
		    var page='<iframe class="iframeTab" scrolling="auto" frameborder="0"  src="' + item.url + '" style="width:100%;height:99%;"></iframe>';
			
            $('#mainTab').tabs('add', {
                title: item.text,
                content: page,
                closable: true,
                icon: item.iconCls,
                id: item.id
            });
        } else {
            $('#mainTab').tabs('select', item.text);
        }
        addTabMenu();
    }

    function addTabMenu() {
        /* 双击关闭TAB选项卡 */
        $(".tabs-inner").dblclick(function () {
            var subtitle = $(this).children(".tabs-closable").text();
            $('#mainTab').tabs('close', subtitle);
        });
		
		
        /* 为选项卡绑定右键 */
        $(".tabs-inner").bind('contextmenu', function (e) {
            $('#tab_menu').menu('show', {
                left: e.pageX,
                top: e.pageY
            });

            var subtitle = $(this).children(".tabs-closable").text();

            $('#tab_menu').data("currtab", subtitle);
            $('#mainTab').tabs('select', subtitle);
            return false;
        });
    }

    function changeMenuSelect(menus, opts, selectId) {
        var menutrees = menus.find(".sidemenu-tree");
        menutrees.each(function () {
            var menuItem = $(this);
            changeMenuStyle(menuItem, opts, selectId);
        });

        var tooltips = menus.find(".tooltip-f");
        tooltips.each(function () {
            var menuItem = $(this);
            var tip = menuItem.tooltip("tip");
            if (tip) {
                tip.find(".sidemenu-tree").each(function () {
                    changeMenuStyle($(this), opts, selectId);
                });
                menuItem.tooltip("reposition");
            }
        });
    }

    function changeMenuStyle(menuItem, opts, selectId) {
        menuItem.find("div.tree-node-selected").removeClass("tree-node-selected");
        var node = menuItem.tree("find", selectId);
        if (node) {
            $(node.target).addClass("tree-node-selected");
            opts.selectedItemId = node.id;
            menuItem.trigger("mouseleave.sidemenu");
        }

        changeMenuSelect(menuItem);
    }
</script>

</head>
<body class="easyui-layout">

<jsp:include page="floatlogin.html"></jsp:include>


	<div data-options="region:'north',border:false" style="height:135px;background:#D0DFF7;padding:1px;overflow:hidden;">
	
	
				<div id="head">
<!-- 		测试可打开		头部 -->
                
				<div id="lefttop">
				<div id="logindiv" class="reg"><a href="javascript:void(0);" id="openLogin"><b>登录</b></a>&nbsp;</div> <div class="reg" id="loguser"></div> <div id="logoutdiv" class="reg user-hide"><a href="javascript:void(0);" id="logout"><b>退出</b></a>&nbsp;</div> <div id="regdiv" class="reg"><a href="javascript:void(0);">&nbsp;注册&nbsp;</a></div>
				 <div class="date"></div> <div class="time"></div>  
				<div class="lang">
				 <a href="javascript:void(0);" onClick="changeLang('CN')">中文</a>    
				 <a href="javascript:void(0);" onClick="changeLang('EN')">英文</a>
				 </div>
				</div>
				
				<div  width="1480" height="135">
				<img src="<%=request.getContextPath()%>/images/top.png"
					alt="logo"    style= "width: 100%;height:125px;"/>
				</div>
			</div>

	</div>
	
	
	<div data-options="region:'west',split:true,title:'菜单',border:false" style="width:208px;padding:1px;">
		 <div style="width:100%;height:100%;">
		   <div id="leftMenuDiv" style="width: 202px;height:100%; background-color: green;">
                <div class="easyui-panel" style="width:100%;height:100%;" data-options="border:false,onOpen:onPanelOpen">
                    <div id="leftMenu">
                    </div>
                </div>
            </div>
	    </div>
	
	</div>
	
	
<!-- 	<div data-options="region:'east',split:true,collapsed:true,title:'East'" style="width:100px;padding:10px;">east region</div> -->
<!-- 	<div data-options="region:'south',border:false" style="height:50px;background:#A9FACD;padding:10px;">south region</div> -->
	
	
	<div data-options="region:'center'">
	
	    <div id="mainTab" class="easyui-tabs" data-options="fit:true,onSelect:onTabSelect">
                <div title="首页" data-options="closable:false" style="overflow:hidden;background-color:#fff;">
                    <iframe scrolling="false" frameborder="0" src="index.html" style="width:100%;height:100%"   seamless></iframe>
                </div>
                
                <div title="Bee" data-options="closable:false" style="overflow:hidden;background-color:#fff;">
                    <iframe scrolling="false" frameborder="0" src="why-is-Bee.html" style="width:100%;height:100%"   seamless></iframe>
                </div>
        </div>
	
	</div>
	
<jsp:include page="tab-action.html"></jsp:include>
	
</body>

</html>